home *** CD-ROM | disk | FTP | other *** search
- Path: sun001.spd.dsccc.com!spd!jmccarty
- From: jmccarty@spd.dsccc.com (Mike McCarty)
- Newsgroups: comp.arch.arithmetic,comp.lang.c,comp.lang.c++
- Subject: Re: Access carry flag from C
- Date: 22 Feb 1996 20:00:24 GMT
- Organization: DSC Communications Corporation, Plano, Texas USA
- Message-ID: <4gii0o$38k@sun001.spd.dsccc.com>
- References: <Dn1C9z.DGv.0.net@indra.com> <31298D20.41C6@bazis.nl> <ARTHUR.96Feb20143404@gold.Smallworld.co.uk> <TANMOY.96Feb20101110@qcd.lanl.gov>
- NNTP-Posting-Host: aplo139.spd.dsccc.com
-
- In article <TANMOY.96Feb20101110@qcd.lanl.gov>,
- Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov> wrote:
- )In article <ARTHUR.96Feb20143404@gold.Smallworld.co.uk>
- )arthur@Smallworld.co.uk (Arthur Chance) writes:
- )<snip>
- ) In article <31298D20.41C6@bazis.nl> Franz Korntner <fkorntne@bazis.nl> writes:
- ) > j+k will overflow when the result exceeds MAXINT
- ) >
- ) > Thus: "if (j+k > MAXINT) overflow();" but the operation is undefined
- ) > if the result overflows, so the expression needs rewriting to make sure
- ) > this doesn't happen. The result is then "if (j>MAXINT-k) overflow();".
- )
- ) As we must be talking about signed ints, because unsigned can't cause
- ) undefined behaviour by overflow, if k < 0, then MAXINT-k overflows.
- )
- ) Basically, the C *standard* is useless on things like signed overflow
- ) (or word size, or what happens with right shift of -ve numbers, or
- ) <insert your favourite "undefined behaviour" gripe here>). You have
- ) to look carefully at each *implementation* you use. You can usually
-
- If I recall the first post properly, no mention was made of "int" types,
- but rather of fixed-point types. Not all fixed-point numeration systems
- represent integers.
-
- )Actually you are mixing up the concepts of `undefined behaviour' and
- )`implementation-defined behaviour'. In the case of the former, even
- )looking at the implementation documentation need not be sufficient: in
- )the latter, the documentation has to tell you what happens.
- )
- )Cheers
- )Tanmoy
- )--
- )tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- )Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- )Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- )<http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- )internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- )fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-
-
- ----
- char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
-
- I don't speak for DSC. <- They make me say that.
-